#include "main.h"
#include "ManKey.h"
#include "global.h"
#include "ndata.h"

ManKey manKey(1);


void manKeyEvent (uint32_t ms, ManKeyEventCode manKeyEventCode){
    uint8_t inx= manKeyEventCode.one.inx;

    switch (manKeyEventCode.one.evtCode)
    {
        case MAN_KEY_EVT_DOWN:
        {
            printf("%d  %d:DOWN\n", ms,inx); break;
        }
        case MAN_KEY_EVT_UP: printf("%d  %d:UP\n", ms,inx); break;
        case MAN_KEY_EVT_CLICK: printf("%d  %d:CLICK\n", ms,inx); break;
        case MAN_KEY_EVT_DBL_CLICK: printf("%d  %d:DBL_CLICK\n",ms, inx); break;
        case MAN_KEY_EVT_PRESSING: printf("%d  %d:PRESSING\n", ms,inx); break;
        case MAN_KEY_EVT_LONG_CLICK: printf("%d  %d:LONG_CLICK\n", ms,inx); break;
    }
}


int manKeyDigitalRead(uint8_t inx){
    return !digitalRead(0);
}


void bspKeyInit(){
    pinMode(0, INPUT_PULLUP);
    ManKey::digitalRead=manKeyDigitalRead;
    ManKey::onEvent=manKeyEvent;
}





